﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Threading;
using System.IO;
using Vit.Common.Helpers;
using Vit.Web.Helpers;

namespace Vit.Web.Mvc.Controllers
{
    public class ThemeController : Controller
    {
        [HttpGet]
        [OutputCache(Duration = 3600, VaryByParam = "id", VaryByCustom = "session")]
        public ActionResult Image(string id)
        {
            var filePath = Theme.Image(id);
            FileInfo fi = new FileInfo(Server.MapPath(filePath));
            return File(filePath, string.Format("image/{0}", fi.Extension));
        }

        [HttpGet]
        [OutputCache(Duration = 3600, VaryByParam = "id", VaryByCustom = "session")]
        public ActionResult Script(string id)
        {
            var filePath = Theme.Script(id);
            FileInfo fi = new FileInfo(Server.MapPath(filePath));
            return File(filePath, string.Format("image/{0}", fi.Extension));
        }

        [HttpGet]
        [OutputCache(Duration = 3600, VaryByParam = "id", VaryByCustom = "session")]
        public ActionResult Style(string id)
        {
            var filePath = Theme.Style(id);
            FileInfo fi = new FileInfo(Server.MapPath(filePath));
            return File(filePath, string.Format("image/{0}", fi.Extension));
        }
    }
}
